#include <stdio.h> 
#include <sys/types.h>
#include <dirent.h>
#include <unistd.h>
#include <string.h>

int Ls(const char * path)
{
	DIR* dir = NULL;
	if(NULL == path)
	{
		dir = opendir(".");
	}
	else
	{
		dir = opendir(path);
	}
	if(NULL == dir)
	{
		perror("opendir");
		return 1;
	}

	
	while(1)
	{	
		struct dirent * info = readdir(dir);
		if(NULL == info)
		{
			break;
		}
		if(info->d_type == DT_DIR)
		{
			if(0 == strcmp(info->d_name,".")||
					0 == strcmp(info->d_name,".."))
			continue;
		}
		printf("%s\n",info->d_name);
	}
	closedir(dir);
	return 0;
}

